package cn.tedu.oop;

/**
 * @Author 金帮嘉诚
 * @Date 2021-06-08 周二 19:58
 */
/*本类用于面向对象2综合练习*/

/**
 * 知识点：
 * 1.无参含参全参构造方法
 * 2.封装 成员变量和方法 的使用
 * 3.构造代码块和局部方法块
 */
public class TestTeacher {
    public static void main(String[] args) {
        Teacher1 teacher1=new Teacher1();
        Teacher1 teacher2=new Teacher1("涛涛","JAVA大数据",18,10000);
        System.out.println("teacher1.getName() = " + teacher1.getName());
        //teacher1.name;不能直接使用private成员变量和方法
        //teacher1.teach();
        teacher1.setName("跑跑跑");
        System.out.println("teacher1.getName() = " + teacher1.getName());

    }
}

class Teacher1 {
    private String name;
    private String subject;
    private int age;
    private double salary;

    {
        System.out.print("  构造代码块结束  ");
    }

    public Teacher1() {
        this("name1","subject1",18,100);
        System.out.println("Non Parameter");
    }

    public Teacher1(String name, String subject, int age, double salary) {
        this.name = name;
        this.subject = subject;
        this.age = age;
        this.salary = salary;
        System.out.println("With Parameter");
    }

    public String getName() {
        return name;
    }
    public void ready(){
        {
            System.out.println("我是一个局部代码块");
            int i=1;
            System.out.println("i = " + i);
        }
        System.out.println("Preparing");
        teach();
    }

    private void teach() {
        System.out.println("Teaching");
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }
}
